// structrectfunction2.c
// gcc structrectfunction2.c

#include <stdio.h>
#include <stdlib.h>

typedef struct point {
    int x;
    int y;
}POINT;

typedef struct rect {
    struct point p1;
    struct point p2;
}RECT;

// function prototype
POINT makePoint(int x, int y);
POINT addPoint(POINT p1, POINT p2);

int main()
{
    RECT screen1;
    
    screen1.p1 = makePoint(5,2);
    screen1.p2 = makePoint(50,20);
    
    printf("screen1 p1( %d , %d )\n", screen1.p1.x , screen1.p1.y);
    printf("screen1 p2( %d , %d )\n", screen1.p2.x , screen1.p2.y);
    printf("\n");
    
    RECT screen2;
    screen2.p1 = screen1.p1;
    screen2.p2 = addPoint( screen1.p1 , screen1.p2 );
    
    printf("screen2 p1( %d , %d )\n", screen2.p1.x , screen2.p1.y);
    printf("screen2 p2( %d , %d )\n", screen2.p2.x , screen2.p2.y);
    printf("\n");
    
    printf("\n");
    system("pause");
    return 0;
}

POINT makePoint(int x, int y)
   {
       struct point temp;
       temp.x = x;
       temp.y = y;
       return temp;
}

POINT addPoint(POINT p1, POINT p2)
   {
       p1.x += p2.x;
       p1.y += p2.y;
       return p1;
}